package com.xyht.sca_s.student_manage_system.modules.leave.controller;


import com.xyht.sca_s.student_manage_system.common.commonReturn.ResponseResult;
import com.xyht.sca_s.student_manage_system.common.desEncodeAndDecode.annotation.SecretBody;
import com.xyht.sca_s.student_manage_system.modules.leave.entity.SmsLeaveProcess;
import com.xyht.sca_s.student_manage_system.modules.leave.entity.req.SmsLeaveProcessReq;
import com.xyht.sca_s.student_manage_system.modules.leave.entity.req.SmsLeaveProcessUpdateReq;
import com.xyht.sca_s.student_manage_system.modules.leave.service.SmsLeaveProcessService;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 请假流程设置 前端控制器
 * </p>
 *
 * @author XYHT
 * @since 2022-12-06
 */
@RestController
@RequestMapping("/leave/process")
@SecretBody
public class SmsLeaveProcessController {
    @Autowired
    private SmsLeaveProcessService smsLeaveProcessService;

    @ApiModelProperty(value = "添加请假流程")
    @PostMapping("/add")
    public ResponseResult addLeaveProcess(@RequestBody SmsLeaveProcessReq smsLeaveProcessReq){
        return smsLeaveProcessService.addLeaveProcess(smsLeaveProcessReq);
    }

    @ApiModelProperty(value = "更新请假流程")
    @PostMapping("/update")
    public ResponseResult updateLeaveProcess(@RequestBody SmsLeaveProcessUpdateReq smsLeaveProcessReq){
        return smsLeaveProcessService.updateLeaveProcess(smsLeaveProcessReq);
    }

    @ApiModelProperty(value = "删除请假流程")
    @PostMapping("/delete")
    public ResponseResult deleteLeaveProcess(@RequestBody SmsLeaveProcess smsLeaveProcess){
        return smsLeaveProcessService.deleteLeaveProcess(smsLeaveProcess);
    }

    @ApiModelProperty(value = "申请添加请假流程（获取开始时间段）")
    @GetMapping("/apply")
    public ResponseResult applyLeaveProcess(){
        return smsLeaveProcessService.applyLeaveProcess();
    }

    @ApiModelProperty(value = "获取请假流程列表")
    @GetMapping("/list")
    public ResponseResult getLeaveProcess(@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                          @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum){
        return smsLeaveProcessService.getLeaveProcess(pageSize,pageNum);
    }

    @ApiModelProperty(value = "获取请假流程详情")
    @GetMapping("/detail")
    public ResponseResult getLeaveProcessDetail(@RequestParam("process_id") String process_id){
        return smsLeaveProcessService.getLeaveProcessDetail(process_id);
    }

    @ApiModelProperty(value = "获取流程最长时间")
    @GetMapping("/max")
    public ResponseResult getTotalHour() {
        return smsLeaveProcessService.getTotalHour();
    }
}

